package com.xyh.springboot.controller;

import com.xyh.springboot.model.UserDTO;
import com.xyh.springboot.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;

import javax.validation.Valid;

/**
 * @Author:kyle
 * @Date:2020/12/28 - 11:38
 * @Project:springboot
 * @Package:com.xyh.springboot.controller
 * @Version:1.0
 */
@Controller("/user")
public class RegisterValidController {

    @Autowired
    private IUserService userService;


    //@Valid验证，BindingResult把错误信息封装在result里面
    @PostMapping("/reg")
    public String Register(@Valid UserDTO user, BindingResult result){

        if(result.hasErrors()){

            return "/src/main/resources/static/register.html";
        }
        return "/src/main/resources/static/register.html";
    }
}
